<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h1>{{name}}</h1>
        <h1>n的值是：{{n}}</h1>
        <h1 v-big="n">放大10倍的值是：</h1>
        <button @click="n++">点我n+1</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        Vue.directive("big",function(element, binding){
            console.log(this);
            element.innerHTML = "放大10倍的值是："+binding.value*10;
        });

        let vm = new Vue({
            el: '#root',
            data: {
                name:'尚硅谷123',
                n:1,
            },
            directives:{
                // big函数何时会被调用
                // 1. 指令与元素成功绑定时
                // 2. 指令所在的模板重新被解析时
                // big(element, binding){
                //     console.log("sfjsk");
                //     element.innerHTML = "放大10倍的值是："+binding.value*10;
                // }
            }
        });
    </script>
</body>
</html>